<?php
namespace Plu\Library\Services;

use Phalcon\DI\Injectable,
    Phalcon\DI,
    Plu\Library\Services\Utility\NumberService;

class ServiceBase extends Injectable {
    public function getRedis($type) {
        $key = sprintf("redis.%s", $type);
        if ($this->di->has($key)) {
            return $this->di->get($key);
        }
        
        //如果后缀带有.slave
        if (strpos($type, ".slave")) {
            return $this->getRedis(str_replace(".slave", "", $type));
        }

        return false;
    }

    static public function getCacheHandler() {
        return DI::getDefault()->get('cache');
    }

    public static function _getDI() {
        return DI::getDefault();
    }

    /**
     * check array is number?
     */
    public function toNumberList($ids) {
        return NumberService::toNumberList($ids);
    }
}
?>
